execute as @e[type=item_frame,nbt={Tags:["item_deleter"]}] run data modify entity @s ItemRotation set value 0
execute as @e[type=item_frame,nbt={Tags:["item_deleter"]}] at @s if entity @e[distance=..1.5,type=item_frame,nbt={Tags:["wire"]},tag=hasPower] if entity @e[distance=..1,type=item,tag=!keep_from_delete] run kill @e[distance=..1,type=item,tag=!keep_from_delete]
execute as @e[type=item_frame,nbt={Tags:["item_deleter"]}] at @s if entity @e[distance=..1.5,type=item_frame,nbt={Tags:["wire"]},tag=hasPower] if entity @e[distance=..1,type=item,tag=!keep_from_delete] run tag @e[distance=..1.5,type=item_frame,nbt={Tags:["wire"]},tag=hasPower,limit=1,sort=random] remove hasPower
execute as @e[type=item_frame,tag=item_deleter] at @s unless block ~ ~-1 ~ red_glazed_terracotta run kill @s